import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.swing.JOptionPane;

public class Connect_sql {
	private static Connection connection;
	public static String user = "root";
    public static String password = "yulazala16";
    public static String url = "jdbc:mysql://localhost:3306/happyhomebuilders";
    private static final String SERVER_ERROR = "Server Connection Error";
    
    
    public static Connection get() {
        try {
            if (connection == null || connection.isClosed()) {
                Class.forName("com.mysql.jdbc.Driver");
                connection = DriverManager.getConnection(url, user, password);
            }
        } catch (ClassNotFoundException ex) {
           
        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage(), SERVER_ERROR, JOptionPane.ERROR_MESSAGE);
        }

        return connection;
        }
	
	public static void close() {

        try {
            if (connection != null) {
                connection.close();
            }
        } catch (SQLException ex) {
            
        }
    }
	
}
